/// @description:
/// @author tangzhentao
/// @created at 22:45 2025/2/16
library;

import 'package:gold/base/config.dart';

/// 获取订单状态的描述
/// [type] 商品类型[ProductType]
/// [status] 订单状态[OrderStatus]
String getOrderStatusDesc(String type, String? status) {
  switch(status) {
    case OrderStatus.paying:
      return '待支付';
    case OrderStatus.sending:
      return '待发货';
    case OrderStatus.receiving:
      return type == ProductType.gold ? '待提货':'待收货';
    case OrderStatus.reviewing:
      return '待评价';
    case OrderStatus.authorized:
      return '已授权';
    case OrderStatus.done:
      return '已完成';
    case OrderStatus.cancel:
      return '已取消';
    default:
      return '全部';
  }
}

/// 获取订单状态的下标
/// [type] 商品类型[ProductType]
/// [status] 订单状态[OrderStatus]
int getOrderStatusIndex(String type, String? status) {
  switch(status) {
    case OrderStatus.paying:
      return 1;
    case OrderStatus.sending:
      return 2;
    case OrderStatus.receiving:
      return 3;
    case OrderStatus.authorized:
      return 4;
    case OrderStatus.done:
      return type == ProductType.gold ? 5:4;
    case OrderStatus.reviewing:
      return type == ProductType.gold ? 6:5;
    case OrderStatus.cancel:
      return type == ProductType.gold ? 7:6;
    default:
      return 0;
  }
}

/// 退款原因列表
final refundReasonList = [
  RefundReason(0, '拍错/多拍/不喜欢'),RefundReason(1, '与商家协商一致退款'),RefundReason(2, '克数不对'),
  RefundReason(3, '未按约定时间发货'),RefundReason(4, '快递/物流一直未送到'),RefundReason(5, '快递/物流无跟踪记录'),
  RefundReason(6, '货物破损已拒签'),
];

/// 获取退款原因描述
String getRefundReasonDesc(int? reason) {
  String desc = '未获取到';
  if (reason != null) {
    for (var rea in refundReasonList) {
      if (reason == rea.reason) {
        desc = rea.desc;
        break;
      }
    }
  }
  return desc;
}

/// 取消订单原因列表
final cancelReasonList = [
  CancelReason(0, '价格有点贵'),CancelReason(1, '规格/款式/数量拍错'),CancelReason(2, '收获地址填错'),
  CancelReason(3, '商家不支持花呗'),CancelReason(4, '暂时不需要了'),CancelReason(5, '其他'),
];

/// 取消订单原因
class CancelReason {
  final int reason;
  final String desc;

  CancelReason(this.reason, this.desc);
}

/// 退款原因
class RefundReason {
  final int reason;
  final String desc;

  RefundReason(this.reason, this.desc);
}